#!/bin/bash

export GO111MODULE=off
NGROK_DOMAIN="aeparkway.com"

mkdir -p cert
cd cert

openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 500000 -out rootCA.pem
openssl genrsa -out server.key 2048
openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr
openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 500000

cp rootCA.pem ../assets/client/tls/ngrokroot.crt
cp server.crt ../assets/server/tls/snakeoil.crt
cp server.key ../assets/server/tls/snakeoil.key

cd ../
mkdir -p bin
go get github.com/jteeuwen/go-bindata/go-bindata
cp -rf $GOPATH/bin/go-bindata bin

GOOS=linux GOARCH=amd64 make release-server
GOOS=windows GOARCH=386 make release-client
GOOS=windows GOARCH=amd64 make release-client
GOOS=darwin GOARCH=amd64 make release-client
